import React, { Suspense, useCallback,useState, useRef, useMemo, useEffect } from "react";
import { Switch } from "react-router-dom";
import CreateRoutesList from "./router/index";
import useWebSocket from "react-use-websocket";
import "./App.css"

const App: React.FC = porps => {
  const [socketUrl] = useState<string>("wss://api.hopex.com/ws");
  const [name,setName] = useState<string>('lxb');
  const options = useMemo(
    () => ({
      share: true,
      fromSocketIO: false
    }),
    []
  );
  const [sendMessage,lastMessage, readyState] = useWebSocket(socketUrl, options);
  const status= useMemo(()=>{
    if(readyState==1){
     
    setInterval(()=>{
      sendMessage('ping')
    },5000)
    }
  },[readyState])
  console.log('app render')
  return (

    <div className="App2">
      <Suspense fallback={<div>Loading...</div>}>
        <Switch>{CreateRoutesList("")}</Switch>
      </Suspense>
    </div>
  );
};

export default App;
